package com.nowcoder;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class SimpleErrorLog {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        fileNames = new String[LEN];
        countArr = new int[LEN];
        lineNumber = new int[LEN];
        ind = 0;
        abandonedFileNameSet = new HashSet<>();
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            onlineSolver(line);
        }
        for (int i = 0; i < LEN && fileNames[i] != null; i++) {
            System.out.println(fileNames[(i + ind) % LEN] + " "
                    + lineNumber[(i + ind) % LEN] + " " + countArr[(i + ind) % LEN]);
        }
    }

    private static final int LEN = 8;

    private static String[] fileNames = new String[LEN];

    private static int[] countArr = new int[LEN];

    private static int[] lineNumber = new int[LEN];

    private static int ind = 0;

    private static Set<String> abandonedFileNameSet = new HashSet<>();

    public static void onlineSolver(String line) {
        int i = 0;
        String[] strs = line.split(" ");
        int lineNum = Integer.valueOf(strs[1]);
        String fileName = strs[0].substring(strs[0].lastIndexOf("\\") + 1);
        int len = fileName.length();
        if (len > 16) {
            fileName = fileName.substring(len - 16);
        }
        for (i = 0; i < LEN; i++) {
            if (fileNames[i] == null
                    || fileNames[i].equals(fileName)
                    && lineNumber[i] == lineNum) {
                fileNames[i] = fileName;
                countArr[i]++;
                lineNumber[i] = lineNum;
                break;
            }
        }
        // 缓存区已满，并且当前文件名是个新文件名，在缓存区查询不到
        if (i == LEN && !abandonedFileNameSet.contains(fileName + lineNum)) {
            abandonedFileNameSet.add(fileNames[ind % LEN] + lineNumber[ind % LEN]);
            fileNames[ind % LEN] = fileName;
            lineNumber[ind % LEN] = lineNum;
            countArr[ind % LEN] = 1;
            ind++;
        }
    }
}
